<?php use_javascripts_for_form($form) ?>
<!-- All forms that used newsucces or editsucces are in a div with the id form -->
<div id="form">  
    <!-- the go back button on the side -->
    <a href="<?php echo url_for('sales/indexContacts') ?>" class="bt_back"><img src="<?php echo image_path('Buttons/bt_arrow_back.png') ?>" onmouseover="this.src='<?php echo image_path('Buttons/bt_arrow_back_hov.png') ?>'" onmouseout="this.src='<?php echo image_path('Buttons/bt_arrow_back.png') ?>'"></a>
    <!-- The actual form itself -->
    <form action="<?php echo url_for('sales/' . ($form->getObject()->isNew() ? 'createContact' : 'updateContact') . (!$form->getObject()->isNew() ? '?id=' . $form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
        <?php if (!$form->getObject()->isNew()): ?>
            <input type="hidden" name="sf_method" value="put" />
        <?php endif; ?>
        <!-- general information of the contact -->
        <fieldset>
            <legend class="bold">General information</legend>
            <p style="color:red;">* required to be filled in</p>
            <table>
                <tr>
                    <!-- Categories for contacts are taken from database because you can add new categories yourself -->
                    <td class="left_title_cat italic">Category: *</td>
                    <td class="radio"><?php echo $form['category_name']->render() ?></td><!-- input field with an ul -->
                    <td class="left_error"><?php echo $form['category_name']->renderError() ?></td><!-- error display in an ul -->     
                </tr>
            </table>
            <table>
                <tr>
                    <td class="left_title italic">Code: *</td>
                    <td class="left_input"><?php echo $form['contact_code']->render() ?></td>
                    <td class="left_error"><?php echo $form['contact_code']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title italic">Name: *</td>
                    <td class="left_input"><?php echo $form['name']->render() ?></td> 
                    <td class="left_error"><?php echo $form['name']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title italic">Contact Person:</td>
                    <td class="left_input"><?php echo $form['contact_person']->render() ?></td>
                    <td class="left_error"><?php echo $form['contact_person']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title italic">Address:</td>
                    <td class="left_input"><?php echo $form['address']->render() ?></td>
                    <td class="left_error"><?php echo $form['address']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title italic">ZIP code:</td>
                    <td class="left_input"><?php echo $form['zipcode']->render() ?></td>
                    <td class="left_error"><?php echo $form['zipcode']->renderError() ?></td>
                    <td class="right_title italic">City:</td>
                    <td class="right_input"><?php echo $form['city']->render() ?></td>
                    <td class="right_error"><?php echo $form['city']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title italic">Country</td>
                    <td class="left_input"><?php echo $form['country']->render() ?></td>
                    <td class="left_error"><?php echo $form['country']->renderError() ?></td>
                </tr>
            </table>
        </fieldset>
        <!-- contact information of the contact -->
        <fieldset>
            <legend class="bold">Contact information</legend>
            <table>
                <tr>
                    <td class="left_title italic">Phone No.:</td>
                    <td class="left_input"><?php echo $form['phone']->render() ?></td>
                    <td class="left_error"><?php echo $form['phone']->renderError() ?></td>
                    <td class="right_title italic">Email:</td>
                    <td class="right_input long_input"><?php echo $form['email']->render() ?></td>
                    <td class="right_error"><?php echo $form['email']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title italic">Mobile No.:</td>
                    <td class="left_input"><?php echo $form['mobile']->render() ?></td>
                    <td class="left_error"><?php echo $form['mobile']->renderError() ?></td>
                    <td class="right_title italic">Website:</td>
                    <td class="right_input long_input"><?php echo $form['website']->render() ?></td>
                    <td class="right_error"><?php echo $form['website']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title italic">Fax No.:</td>
                    <td class="left_input"><?php echo $form['fax']->render() ?></td>
                    <td class="left_error"><?php echo $form['fax']->renderError() ?></td>
                </tr>
            </table>
        </fieldset>
        <!-- bank information of contact -->
        <fieldset>
            <legend class="bold">Bank information</legend>
            <table>
                <tr>
                    <td class="left_title italic">Bank:</td>
                    <td class="left_input"><?php echo $form['bank']->render() ?></td>
                    <td class="left_error"><?php echo $form['bank']->renderError() ?></td>
                    <td class="right_title italic">Bank Account No.:</td>
                    <td class="right_input"><?php echo $form['bank_account']->render() ?></td>
                    <td class="right_error"><?php echo $form['bank_account']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title italic">IBAN:</td>
                    <td class="left_input"><?php echo $form['IBAN']->render() ?></td>
                    <td class="left_error"><?php echo $form['IBAN']->renderError() ?></td>
                    <td class="right_title italic">BIC:</td>
                    <td class="right_input"><?php echo $form['BIC']->render() ?></td>
                    <td class="right_error"><?php echo $form['BIC']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title italic">VAT:</td>
                    <td class="left_input"><?php echo $form['VAT']->render() ?></td>
                    <td class="left_error"><?php echo $form['VAT']->renderError() ?></td>
                </tr>
            </table>
        </fieldset>
        <!-- option to write down some extra other information of contact -->
        <fieldset>
            <legend class="bold">Notes</legend>
            <div id="contact_note">
            <?php echo $form['note']->render() ?>
            </div>
        </fieldset>
        <input type="submit" value="" class="ok"/>
        <!-- the token -->
        <div class="hidden_csrf"><?php echo $form['_csrf_token']->renderRow(); ?></div>
    </form>
</div><!-- close div form -->
